package com.py.credit.service.impl;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.py.credit.dao.ModifyLoggerDao;
import com.py.credit.service.ModifyLogService;
import com.py.credit.utils.SQLBuilder;
import com.py.framework.core.common.Page;

@Service
public class ModifyServiceImpl implements ModifyLogService {

	@Autowired
	private ModifyLoggerDao modifyLogDao;

	@Override
	public List<LinkedHashMap> selectModifyOperById(String processId) {
		return modifyLogDao.selectModifyOperById(processId);
	}

	@Override
	public List<LinkedHashMap> selectModifyLogByForPage(String mainType, String tablename, String mainName, String bm,
			Page page) {
		Map<String, String> params = new HashMap<>();
		params.put("tablename", tablename);
		params.put("mainName", mainName);
		params.put("bm", bm);
		params.put("mainType", mainType);
		return modifyLogDao.selectModifyLogByForPage(params, page);
	}

	@Override
	public void updateCheckById(String id, String shzt, String bz, String shyj, String shr) {
		Map<String, String> params = new HashMap<>();
		params.put("id", id);
		params.put("shzt", shzt);
		params.put("bz", bz);
		params.put("shyj", shyj);
		params.put("shr", shr);
		modifyLogDao.updateCheckById(params);
	}

	@Override
	public void updateCheckNoteById(String recordId, String idAuditing) {
		Map<String, String> params = new HashMap<>();
		params.put("recordId", recordId);
		params.put("idAuditing", idAuditing);
		modifyLogDao.updateCheckNoteById(params);
	}

	@Override
	public List<LinkedHashMap> selectUserOperForPage(String mainType, String username, String ztmc, Page page) {
		Map<String, String> params = new HashMap<>();
		params.put("mainType", mainType);
		params.put("cjr", username);
		params.put("mainName", ztmc);
		return modifyLogDao.selectUserOperForPage(params, page);
	}

	@Override
	public List<LinkedHashMap> selectCheckResultByCjrForPage(String cjr, Page page) {

		return modifyLogDao.selectCheckResultByCjrForPage(cjr, page);
	}

	@Override
	public List<LinkedHashMap<String, Object>> selectByConditionForPage(String mainType, String tablename,
			String mainName, String bm, List<String> columns, String[] additionalColumns, String conditionStr,
			Page page) {
		List<String> conditions = SQLBuilder.createConditionSql(conditionStr);
		Map<String, String> params = new HashMap<>();
		params.put("tablename", tablename);
		params.put("mainName", mainName);
		params.put("bm", bm);
		params.put("mainType", mainType);
		List<LinkedHashMap<String, Object>> ModifyLogs = modifyLogDao.selectByConditionForPage(params, columns,
				additionalColumns, conditions, page);

		return ModifyLogs;
	}

}
